<!-- WEB CONTENT -->
<div id="container_content">
    <div id="ad_main_name">
        <h2>Sell Your Car Parts</h2>
    </div><br/>
    <div id="sell_your_ride_holder">
        <form method="POST" action="<?php echo ($data->adv_id ? '?p=adv_edit_parts&adv_id='.$data->adv_id : '?p=adv_add_parts');?>" enctype="multipart/form-data">
            <input type="hidden" name="seller_id" value="<?php echo $_SESSION['user_data']['user_id']; ?>"/>
            <div id="vehicle_state">
                <h2>Car Part Details</h2>
                <div class="sell_your_raid_inputs_holder">
                    <ul>
                        <li>
                            <div class="sell_your_ride_input">
                                <h3>Year*</h3>
                                <select name="year" id="year">
                                    <option value="">-- select --</option>
                                    <?php
                                    $current_year = date("Y");
                                    for($i=$current_year; $i>=1940; $i--) {
                                        if($i == $data->year) {
                                            echo "<option value='".$i."' selected>${i}</option>";
                                        } else {
                                            echo "<option value='".$i."'>${i}</option>";
                                        }
                                    }
                                    ?>
                                </select>
                            </div>
                        </li>
                        <li>
                            <div class="sell_your_ride_input">
                                <h3>Make</h3>
                                <select name="make" id="make" onchange="get_model(this.value)">
                                    <option value="">-- select --</option>
                                    <?php
                                    foreach ($data->lists['makes'] as $v) {
                                        if($v == $data->make) {
                                            echo "<option value='".$v."' selected>${v}</option>";
                                        } else {
                                            echo "<option value='".$v."'>${v}</option>";
                                        }
                                    }
                                    ?>
                                </select>
                            </div>
                        </li>
                        <li>
                            <div class="sell_your_ride_input">
                                <h3>Model</h3>
                                <select name="model" id="model">
                                    <option value="">-- select --</option>
                                </select>
                            </div>
                        </li>
                    </ul>
                </div>
                <div id="car_features_holder">
                    <h2>Features</h2>
                    <ul>
                        <li>
                            <div class="car_features">
                                <h3>Price(Naira)*</h3>
                                <label for="price"></label> <input type="text" name="price" id="price" value="<?php echo $data->price; ?>" />
                            </div>
                        </li>
                    </ul>
                </div>
                <div id="sell_your_car_description">
                    <h2>Description</h2>
                    <label for="description"></label>
                    <textarea name="description" id="description"><?php echo ($data->description ? $data->description : '');?></textarea>
                </div>
                <div id="car_contact_info_holder">
                    <h2>Contact Info</h2>
                    <ul>
                        <li>
                            <div class="car_features">
                                <h3>Name*</h3>
                                <label for="contact_name"></label>
                                <input type="text" name="contact_name" id="contact_name" value="<?php echo $data->contact_name; ?>" />
                            </div>
                        </li>
                        <li>
                            <div class="car_features">
                                <h3>Mobile*</h3>
                                <label for="contact_phone"></label>
                                <input type="text" name="contact_phone" id="contact_phone" value="<?php echo $data->contact_phone; ?>" />
                            </div>
                        </li>
                        <li>
                            <div class="car_features">
                                <h3>Email*</h3>
                                <label for="contact_email"></label>
                                <input type="text" name="contact_email" id="contact_email" value="<?php echo $data->contact_email; ?>" />
                            </div>
                        </li>
                        <li>
                            <div class="car_features">
                                <h3>City</h3>
                                <label for="contact_city"></label>
                                <input type="text" name="contact_city" id="contact_city" value="<?php echo $data->contact_city; ?>" />
                            </div>
                        </li>
                    </ul>
                </div>
                <div id="car_sale_gallery">
                    <h2>Gallery</h2>

                    <div class="upload_file_gallery1">
                        <?php
                        if(!empty($data->picture1)) {
                            echo "<img src='".$data->picture1."' />";
                        }
                        ?>
                        <div class="delete"></div>
                        <label for="picture1"></label> <input type="file" name="picture1" id="picture1" />
                    </div>

                    <div class="mini_picutres_holder">


                        <div class="upload_file_gallery">
                            <?php
                            if(!empty($data->picture2)) {
                                echo "<img src='".$data->picture2."' />";
                            }
                            ?>
                            <div class="delete"></div>
                            <label for="picture2"></label> <input type="file" name="picture2" id="picture2" />
                        </div>


                        <div class="upload_file_gallery">
                            <?php
                            if(!empty($data->picture3)) {
                                echo "<img src='".$data->picture3."' />";
                            }
                            ?>
                            <div class="delete"></div>
                            <label for="picture3"></label> <input type="file" name="picture3" id="picture3" />
                        </div>

                        <div class="upload_file_gallery">
                            <?php
                            if(!empty($data->picture4)) {
                                echo "<img src='".$data->picture4."' />";
                            }
                            ?>
                            <div class="delete"></div>
                            <label for="picture4"></label> <input type="file" name="picture4" id="picture4" />
                        </div>


                        <div class="upload_file_gallery">
                            <?php
                            if(!empty($data->picture5)) {
                                echo "<img src='".$data->picture5."' />";
                            }
                            ?>
                            <div class="delete"></div>
                            <label for="picture5"></label> <input type="file" name="picture5" id="picture5" />
                        </div>


                        <div class="upload_file_gallery">
                            <?php
                            if(!empty($data->picture6)) {
                                echo "<img src='".$data->picture6."' />";
                            }
                            ?>
                            <div class="delete"></div>
                            <label for="picture6"></label> <input type="file" name="picture6" id="picture6" />
                        </div>


                        <div class="upload_file_gallery">
                            <?php
                            if(!empty($data->picture7)) {
                                echo "<img src='".$data->picture7."' />";
                            }
                            ?>
                            <div class="delete"></div>
                            <label for="picture7"></label> <input type="file" name="picture7" id="picture7" />
                        </div>



                        <div class="upload_file_gallery">
                            <?php
                            if(!empty($data->picture8)) {
                                echo "<img src='".$data->picture8."' />";
                            }
                            ?>
                            <div class="delete"></div>
                            <label for="picture8"></label> <input type="file" name="picture8" id="picture8" />
                        </div>


                        <div class="upload_file_gallery">
                            <?php
                            if(!empty($data->picture9)) {
                                echo "<img src='".$data->picture9."' />";
                            }
                            ?>
                            <div class="delete"></div>
                            <label for="picture9"></label> <input type="file" name="picture9" id="picture9" />
                        </div>




                    </div>
                </div>
            </div>
            </div>
    <div id="submit_advartise">
    <ul>
                            <li><label for="tac"></label><input type="checkbox" name="tac" id="tac" value="1"></li>
                            <li>
                                <p>
                                    I agree to the <span>Advertiser Terms & Conditions</span>
                                </p>
                            </li>
                        </ul>
    <input type="image" src="img/submit_advartise.png" value="Submit Advertise" name="submit"/>
    </div>
        </form>
    </div>
</div>

<script>
    //update model dynamically from database
    function get_model($make, $selected_model) {
        if ($make=="") {
            document.getElementById("model").innerHTML = "";
            return;
        }

        if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp = new XMLHttpRequest();
        }
        else {// code for IE6, IE5
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }

        xmlhttp.onreadystatechange = function() {
            if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                document.getElementById("model").innerHTML = xmlhttp.responseText;
            }
        };

        xmlhttp.open("GET","?p=get_models&make=" + $make + "&selected_model=" + $selected_model, true);
        xmlhttp.send();
    }

    <?php
     if(isset($data->model)) {
        echo "get_model('".urlencode($data->make)."', '".urlencode($data->model)."');";
     }
    ?>
</script>